﻿@using Jqpress.Framework.Mvc
@using Jqpress.Framework.Web;
@model Jqpress.Web.Areas.Admin.Models.CateModel
@{
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
    ViewBag.Title = Model.Category.CategoryId > 0 ? "修改分类 - 管理中心 - Powered by Jqpress" : "添加分类 - 管理中心 - Powered by Jqpress";
}

  
<!-- TinyMCE -->
<script type="text/javascript" src="/common/editors/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
    tinyMCE.init({
        // General options
        mode: "exact",
        elements: "CategoryContent",
        theme: "advanced",
        language: "zh-cn",

        plugins: "autolink,lists,spellchecker,style,save,advhr,advimage,advlink,emotions,inlinepopups,insertdatetime,searchreplace,contextmenu,paste,fullscreen,xhtmlxtras,insertcode", //autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,insertcode
        // Theme options
        theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect,insertcode",
        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,|,forecolor,backcolor,insertcode|,fullscreen",
        theme_advanced_buttons3: "", //tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen
        theme_advanced_buttons4: "", //insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,blockquote,pagebreak,|,insertfile,imagemanager,insertcode
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: true,


        // Example content CSS (should be your site CSS)
        content_css: "/common/editors/css/content.css",

        // Drop lists for link/image/media/template dialogs
        template_external_list_url: "/common/editors/lists/template_list.js",
        external_link_list_url: "/common/editors/lists/link_list.js",
        external_image_list_url: "/common/editors/lists/image_list.js",
        media_external_list_url: "/common/editors/lists/media_list.js",

        // Style formats
        style_formats: [
			{ title: 'Bold text', inline: 'b' },
			{ title: 'Red text', inline: 'span', styles: { color: '#ff0000'} },
			{ title: 'Red header', block: 'h1', styles: { color: '#ff0000'} },
			{ title: 'Example 1', inline: 'span', classes: 'example1' },
			{ title: 'Example 2', inline: 'span', classes: 'example2' },
			{ title: 'Table styles' },
			{ title: 'Table row 1', selector: 'tr', classes: 'tablerow1' }
		],

        // Replace values for the template plugin
        template_replace_values: {
            username: "Some User",
            staffid: "991234"
        }
    });
</script>
<!-- /TinyMCE -->
<script type="text/javascript">

    function addFileToEditor(fileUrl, fileExtension) {

        if (fileExtension == '.gif' || fileExtension == '.jpg' || fileExtension == '.jpeg' || fileExtension == '.bmp' || fileExtension == '.png') {
            var imageTag = "<img src=\"" + fileUrl + "\"/>";
            tinyMCE.execCommand('mceInsertContent', false, imageTag);

        } else {
            var imageTag = "<a href=\"" + fileUrl + "\">" + fileUrl + "</a>";
            tinyMCE.execCommand('mceInsertContent', false, imageTag);
        }

    }

    function createSummary(type) {
        var CategoryContent = tinyMCE.activeEditor.getContent();
        var CategorySummary = $("#Summary");

        if (type == 'full') {
            CategorySummary.text(CategoryContent);
        }
        else {
            CategorySummary.text(CategoryContent.replace(/<[^>]+>/g, "").substring(0, 300));
        }
        return false;
    }
</script>
<script type="text/javascript">
    function checkForm() {
        var title = $("#Title");
        var content = $("#CategoryContent");

        if (title.text() == "") {
            //$("#lableTitle").css("color","red");
            //return false;
        }
        if (content.text() == "") {
            // return false;
        }
    }
</script>

<script type="text/javascript">
    function modalClose() {
        $("#file-close").click();
    }
    $(document).ready(function () {
        $("#CateType").change(function () {
            var _type = $("#CateType").val();
            if (_type == 3) {
                $("#Description").show();
            } else {
                $("#Description").hide();            
            }

        });

    });

</script>
<!-- BEGIN PAGE HEADER-->
<div class="row">
<div class="col-md-12">
    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
    <h3 class="page-title">
        @(Model.Category.CategoryId > 0 ? "编辑" : "添加")分类 
    </h3>
    <!-- END PAGE TITLE & BREADCRUMB-->
</div>
</div>
<!-- END PAGE HEADER-->



 @Html.JPartial("_Notifications")


<div class="portlet-body form">
    <form name="form1" method="post" action="@Url.Action("Save", "Category")" enctype="multipart/form-data" >
    <input type="hidden"  id="CategoryId" name="CategoryId" value="@Model.Category.CategoryId" />

    <div class="form-body">
                           
        <div class="form-group">
            <label for="CateName">名称：</label>
            <input type="text" id="CateName" name="CateName" value="@Model.Category.CateName" class="form-control"  style="width:80%" />
        </div>

        <div class="form-group">
            <label for="CategoryId">父类：</label>
            @Html.DropDownList("ParentId", Model.CateSelectItem, new { @class = "form-control input-medium" })
        </div>
        <div class="form-group">
            <label for="Type">类型：</label>
            @Html.DropDownList("Type", Model.CateType, new { @class = "form-control input-medium" })
            <span>单页面指类似关于我们之类的非产品和新闻的分类。</span>
        </div>
        <div class="form-group">
            <label for="PageName">别名：</label>
            <input type="text" id="PageName" name="PageName" value="@Model.Category.PageName" class="form-control"  style="width:20%" />
            <span>“别名”是对于 URL 友好的一个别称。它通常为小写并且只能包含字母，中文，数字和连字符（-）。</span>
        </div>

        <div class="form-group">
            <label for="PageName">排序：</label>
            <input type="text" id="SortNum" name="SortNum" value="@Model.Category.SortNum" class="form-control"  style="width:20%" />
            <span>数字越小越靠前</span>
        </div>
        @{
            var display = "display:none";
            if(Model.Category.Type==3)
            {
                display = "display:block";
            }   
         }
        <div class="form-group" id="Description" style="@display">
            <a href="#filemodal" title="插入图片/文件"  data-toggle="modal" >插入图片/文件</a>
            <textarea name="Description" rows="2" cols="20" id="CategoryContent" style="height:400px;width:95%;">@Model.Category.Description</textarea>
        </div>
                         
        <div class="form-group">
            <button type="submit" name="btnEdit"  onclick="return checkForm();" id="btnEdit" class="btn btn-primary" >@(Model.Category.CategoryId > 0 ? "修改" : "添加")</button>
            <button type="button" class="btn btn-default" onclick="history.go(-1)" >返回 </button>
        </div>


    </div>
                        
    </form>

    <div id="filemodal" class="modal fade" tabindex="-1" aria-hidden="true">
    <div class="modal-dialog" style="width:80%!important; height:90% !important">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" id="file-close" class="close" data-dismiss="modal" aria-hidden="true"></button>
            </div>
            <div class="modal-body">
                <div class="scroller" style="height:500px; width:100%" data-always-visible="1" data-rail-visible1="1">
                <iframe  height="80%" id="ifrmfile"  src="/admin/files/list" frameBorder="0" width="99.6%"></iframe> 
                </div>
            </div>
                             
        </div>
    </div>
    </div>

</div>

